;;;Requires (ARXUNLOAD "ACDIM") before first run to enable this defun in lieu of AutoCAD's built in DIMension functions.
;;;typing (ARXLOAD "ACDIM") at the command prompt will load ACDIM.ARX restoring the default DIM command.
;;;
;;;Purpose:
;;;
;;;    Automatically set view dependent layers for dimensions within floating viewports so that their display can easily
;;;    be isolated to the view they are in.
;;;
;;;Limitations:
;;;
;;;    This function can only be used for Horizontal or Vertical dimensions.
;;;    While using this function you cannot select the entity to dimension, you must select both extension line origins.
;;;
;;;Subroutines used:
;;;
;;;    mklayr.lsp, gvpno.lsp, ukword.lsp, upoint.lsp, ustr.lsp
;;;
;;;	Author:	Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;		http://paracadd.com
;;;		All rights reserved.
;;;
;;;		COPYRIGHT: 6-19-2009
;;;		   EDITED: 2-10-2011
;;;
(DEFUN C:DIM ()
  (SETQ old_dim_layer (GETVAR "clayer"))
  (IF c:mklayr
    nil
    (LOAD "mklayr")
  ) ;_ end of if
  (c:svlayr)
  (IF set_mjrg NIL (LOAD "SET_MJRG" "\nFile SET_MJRG.LSP not loaded! "))
  (set_mjrg)
  (SETQ
    llt	  "-"
    colra nil
    colri nil
    colr "6"
    modf  "DIMS"
  ) ;_ end of SETQ
  (IF gvpno
    nil
    (LOAD "gvpno")
  ) ;_ end of if
  (SETQ first_key nil)
  (WHILE (NOT (EQ first_key "Exit"))
    (COMMAND nil nil nil)
    (SETQ first_key (ukword 1 "HORizontal VERtical Exit" "DIM>>:" (IF first_key first_key nil)));ANGular DIAmeter RADius 
    (IF (NOT (EQ first_key "Exit"))
      (PROGN
        (SETQ dimpt_1 (upoint 1 "" "Specify first extension line origin" nil nil))
        (gvpno)
        (c:mklayr)
        (COMMAND ".DIM" first_key dimpt_1 (SETQ dimpt_2 (upoint 1 "" "Specify second extension line origin" nil dimpt_1)))
        (SETQ old_dim_osmode (GETVAR "osmode"))
        (SETVAR "osmode" 0)
        (PRINC "\nSpecify dimension line location")
        (COMMAND pause)
        (SETVAR "osmode" old_dim_osmode)
        (SETQ this_dim_text (ustr 1 "Enter dimension text" (RTOS (DISTANCE dimpt_1 dimpt_2) (GETVAR "DIMLUNIT")(GETVAR "DIMDEC")) T))
        (IF (WCMATCH this_dim_text (RTOS (DISTANCE dimpt_1 dimpt_2) (GETVAR "DIMLUNIT")(GETVAR "DIMDEC")))
          (SETQ this_dim_text "")
        )
        (COMMAND this_dim_text)
      )
      (COMMAND "Exit")
    )
  )
  (c:rslayr)
  (IF (MEMBER "acdim.arx" (ARX))
    (ARXUNLOAD "ACDIM")
  )
  (PRINC)
)